/**
 * @author cqg001
 * @param object
 * @description 处理objectId的中间件,可以把objectID混入请求体里面
 */
const mongoose = require('mongoose')
const { ObjectId } = mongoose.Types
const objectId = function (...keys) {
    return function (req, res, next) {
        const objective = {}
        keys.forEach(key => {
            objective[key] = ObjectId()
        })
        req.body = { ...req.body, ...objective }
        next()
    }
}
module.exports = objectId
